<?php
namespace zake\foundation\able\stream;

use zake\foundation\able\ProtocolAble;

interface ReadBufferAble extends ReadAble,ReadPointAble
{
    /**
     * 获取读缓冲区,不会刷新缓冲区
     *
     * @return string
     * @author liu.bin 2020-03-24 13:56
     */
    public function getReadBuffer();


    /**
     * 将数据写入读缓冲区
     * @param ProtocolAble $protocol
     * @param \Closure $callback
     * @param null $closeCallBack
     * @return mixed
     *
     * @author liu.bin 2020-05-19 17:17
     */
    public function readBuffer(ProtocolAble $protocol,\Closure $callback,$closeCallBack=null);


    /**
     * 读取读缓冲区的数据并刷新缓冲区
     *s
     * 如果读取的长度不够，则不会读取，返回空字符串
     *
     * @param int|null $size 需要读取缓冲区的长度
     * @return string
     * @author liu.bin 2020-03-27 10:26
     */
    public function shiftReadBuffer($size=null);


    /**
     * 重置当前缓冲区
     *
     * @param string $buffer
     * @return mixed
     *
     * @author liu.bin 2020-08-18 17:27
     */
    public function resetReadBuffer($buffer="");


    /**
     * 获取当前包长
     * @return int
     *
     * @author liu.bin 2020-08-18 17:24
     */
    public function getPackageLength();


    /**
     * 定义当前包长
     * @param $packageLength
     *
     * @author liu.bin 2020-08-18 17:24
     */
    public function setPackageLength($packageLength);


}